#!/bin/bash

# --- Configuration for reverse_tunnel.sh ---

# --- Remote Server Details ---
# User on the remote (external) server
REMOTE_USER="your_remote_user"

# IP address or hostname of the remote (external) server
REMOTE_HOST="your_remote_server_ip_or_hostname"

# (Optional) SSH port on the remote server if not 22
# REMOTE_SSH_PORT="22"

# --- Tunnel Configuration ---
# The port on the REMOTE server that will be forwarded to your LOCAL machine's SSH port (or other service).
# Make sure this port is not in use on the REMOTE server and is allowed by its firewall.
# Example: If set to 2222, you can ssh to your local machine via: ssh -p 2222 your_local_user@REMOTE_HOST
REMOTE_PORT_FORWARD="2222"

# The local port on THIS machine that the remote port will connect to.
# Typically, this is your local SSH server port (usually 22).
# If you want to forward a different local service, change this port accordingly.
LOCAL_PORT_TO_FORWARD="22"

# --- SSH Key (Highly Recommended) ---
# Specify the path to the private SSH key to be used for authentication.
# If commented out or empty, ssh will use its default key (~/.ssh/id_rsa or others).
# Ensure this key is passwordless or use ssh-agent.
# SSH_IDENTITY_FILE="~/.ssh/id_rsa_reverse_tunnel"

# --- Autossh Options (Advanced) ---
# Autossh monitoring port. If -M is 0, autossh uses SSH keep-alive messages.
# If you set a port (e.g., 20000), ensure it's not used locally.
# Using 0 is generally fine and simpler.
AUTOSSH_MONITOR_PORT="0"

# How often (in seconds) to send SSH keep-alive messages.
AUTOSSH_SERVER_ALIVE_INTERVAL="60"

# How many unanswered keep-alive messages before autossh considers the connection dead.
AUTOSSH_SERVER_ALIVE_COUNT_MAX="3"

# For initial setup, 'no' can be easier. For better security, change to 'yes' 
# after the first successful connection and the host key is in known_hosts.
AUTOSSH_STRICT_HOST_KEY_CHECKING="no"

# For initial setup, '/dev/null' prevents issues with changing host keys.
# For better security, remove this or point to a specific known_hosts file after initial setup.
AUTOSSH_USER_KNOWN_HOSTS_FILE="/dev/null"

# (Optional) Log file for autossh. If not set, autossh might log to syslog.
# AUTOSSH_LOGFILE="/tmp/autossh_reverse_tunnel.log"

# (Optional) Set autossh debug level.
# AUTOSSH_DEBUG="-d"

# (Optional) Any other ssh options you want to pass.
# EXTRA_SSH_OPTIONS="-o SomeOtherOption=value"

